const koa = require("koa");
const router = require("koa-router");

const app = new koa();

const testRouter = new router();

testRouter.get("/", (ctx, next) => {
  ctx.body = "test";
  // maxAge ms
  ctx.cookies.set("name", "lwt", {
    maxAge: 50 * 1000,
  });
});
testRouter.get("/demo", (ctx, next) => {
  const name = ctx.cookies.get("name");
  ctx.body = `你的cookie是${name}`;
});

app.use(testRouter.routes());
app.use(testRouter.allowedMethods());
app.listen(8001, () => {
  console.log("服务器");
});
